package com.netstar.property;

import java.util.HashMap;

public abstract class PropertyClass {

	public String className;
	public Class<? extends Property> objectClass;
	public HashMap<String, AbstractProperty> properties;

	public abstract Property factory();

	private void mixinParentProperties(Class<?> objectClass) {
		if (objectClass != Property.class) {
			Class<?> superClass = objectClass.getSuperclass();
			// get super first, add our stuff on the way back down.
			mixinParentProperties(superClass);

			PropertyClass klass = Property.getKlass(superClass);
			for (String propName : klass.properties.keySet()) {
				properties.put(propName, klass.properties.get(propName));
			}
		}
	}

	public PropertyClass(Class<? extends Property> objectClass, String className) {
		this.objectClass = objectClass;
		this.className = className;
		properties = new HashMap<String, AbstractProperty>();

		// add properties from parent classes, all the way up to the top.
		mixinParentProperties(objectClass);
	}
}
